home *** CD-ROM | disk | FTP | other *** search
/ Champak 114 / Vol 114.iso / games / spongebo.swf / scripts / DefineSprite_729 / frame_5 / DoAction.as
Encoding:
Text File  |  2010-08-12  |  2.9 KB  |  119 lines

  1. scrolling = function()
  2. {
  3.    var _loc5_ = scrollTrack._height;
  4.    var _loc2_ = contentMain._height + 20;
  5.    var _loc4_ = scrollFace._height;
  6.    var _loc3_ = maskedView._height;
  7.    var initPosition = scrollFace._y = scrollTrack._y;
  8.    var initContentPos = contentMain._y + 5;
  9.    var finalContentPos = _loc3_ - _loc2_ + initContentPos;
  10.    var left = scrollTrack._x;
  11.    var top = scrollTrack._y;
  12.    var right = scrollTrack._x;
  13.    var bottom = scrollTrack._height - _loc4_ + scrollTrack._y;
  14.    var dy = 0;
  15.    var speed = 10;
  16.    var moveVal = (_loc2_ - _loc3_) / (_loc5_ - _loc4_);
  17.    scrollFace.onPress = function()
  18.    {
  19.       var _loc2_ = this._y;
  20.       startDrag(this,0,left,top,right,bottom);
  21.       this.onMouseMove = function()
  22.       {
  23.          dy = Math.abs(initPosition - this._y);
  24.          contentMain._y = Math.round(dy * -1 * moveVal + initContentPos);
  25.       };
  26.    };
  27.    scrollFace.onMouseUp = function()
  28.    {
  29.       stopDrag();
  30.       delete this.onMouseMove;
  31.    };
  32.    btnUp.onPress = function()
  33.    {
  34.       this.onEnterFrame = function()
  35.       {
  36.          if(contentMain._y + speed < maskedView._y)
  37.          {
  38.             if(scrollFace._y <= top)
  39.             {
  40.                scrollFace._y = top;
  41.             }
  42.             else
  43.             {
  44.                scrollFace._y -= speed / moveVal;
  45.             }
  46.             contentMain._y += speed;
  47.          }
  48.          else
  49.          {
  50.             scrollFace._y = top;
  51.             contentMain._y = maskedView._y;
  52.             delete this.onEnterFrame;
  53.          }
  54.       };
  55.    };
  56.    btnUp.onDragOut = function()
  57.    {
  58.       delete this.onEnterFrame;
  59.    };
  60.    btnUp.onRollOut = function()
  61.    {
  62.       delete this.onEnterFrame;
  63.    };
  64.    btnUp.onRelease = function()
  65.    {
  66.       delete this.onEnterFrame;
  67.    };
  68.    btnDown.onPress = function()
  69.    {
  70.       this.onEnterFrame = function()
  71.       {
  72.          if(contentMain._y - speed > finalContentPos)
  73.          {
  74.             if(scrollFace._y >= bottom)
  75.             {
  76.                scrollFace._y = bottom;
  77.             }
  78.             else
  79.             {
  80.                scrollFace._y += speed / moveVal;
  81.             }
  82.             contentMain._y -= speed;
  83.          }
  84.          else
  85.          {
  86.             scrollFace._y = bottom;
  87.             contentMain._y = finalContentPos;
  88.             delete this.onEnterFrame;
  89.          }
  90.       };
  91.    };
  92.    btnDown.onRelease = function()
  93.    {
  94.       delete this.onEnterFrame;
  95.    };
  96.    btnDown.onDragOut = function()
  97.    {
  98.       delete this.onEnterFrame;
  99.    };
  100.    btnDown.onRollOut = function()
  101.    {
  102.       delete this.onEnterFrame;
  103.    };
  104.    if(_loc2_ < _loc3_)
  105.    {
  106.       scrollFace._visible = false;
  107.       btnUp.enabled = false;
  108.       btnDown.enabled = false;
  109.    }
  110.    else
  111.    {
  112.       scrollFace._visible = true;
  113.       btnUp.enabled = true;
  114.       btnDown.enabled = true;
  115.    }
  116. };
  117. scrolling();
  118. stop();
  119.